﻿<%@ WebHandler Language="C#" Class="ShowListIntentMoneyPrint" %>

using System;
using System.Web;
using System.Text;
using System.Collections.Generic;
using System.Data;
using Chenxin.Lib.Utility;
using Chenxin.Lib.Business;
using Chenxin.Lib.Business.BLL;

public class ShowListIntentMoneyPrint : AjaxHandlerBase
{

    override public void RequestProcess(HttpContext context)
    {
        try
        {
            context.Response.ContentType = "text/plain";
            context.Response.AddHeader("pragma", "no-cache");
            context.Response.AddHeader("cache-control", "");
            context.Response.CacheControl = "no-cache";

            string strOp = context.Request["op"];
            string strRet = string.Empty;
            switch (strOp.ToLower())
            {
                //添加报备相关信息
                case "getlist":
                    GetList(context);
                    break;
                default:
                    break;
            }
        }
        catch (Exception ex)
        {
            context.Response.Write(retExecResult(Constants.ExecResult.Error, ex.Message, ""));
        }
    }

    private void GetList(HttpContext context)
    {
        StringBuilder sb = new StringBuilder();
        sb.AppendFormat(" 1=1 and BillType='{0}'", context.Request["billtype"]);
        if (!string.IsNullOrEmpty(context.Request["Addtime"]))
        {
            sb.AppendFormat(" and PrintTime>'{0}'", context.Request["Addtime"]);
        }
        if (!string.IsNullOrEmpty(context.Request["Endtime"]))
        {
            sb.AppendFormat(" and PrintTime<'{0}'", DateTime.Parse(context.Request["Endtime"]).AddDays(1));
        }
        if (!string.IsNullOrEmpty(context.Request["keyword"]))
        {
            sb.AppendFormat(" and IntentionCode like '%{0}%'", context.Request["keyword"]);
        }

        //页码
        int strPageIndex = (string.IsNullOrEmpty(context.Request["pageindex"])) ? 1 : int.Parse(context.Request["pageindex"]) + 1;//页码
        //页显示行数
        int strPageSize = (string.IsNullOrEmpty(context.Request["pagesize"])) ? 30 : int.Parse(context.Request["pagesize"]);//页记录数
        string strOrderField = "PrintTime desc";
        DataSet ds = Chenxin.Lib.Business.DAL.System_TraceInfo.GetList(strPageIndex, strPageSize, strOrderField, "t_Intention_BillPrintInfo", sb.ToString(), "*", "*", true);

        context.Response.Write(string.Format("{{success:1,msg:'',data:{{count:{0},{1}}}}}", ds.Tables[1].Rows[0][0], Chenxin.Lib.Utility.JsonHelp.Convert2Json(ds.Tables[0]))); 
    }
    
}